<?php

$client = stream_socket_client(
    'tcp://127.0.0.1:8000',
    $errno,
    $errStr,
    1,
    STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT
);

socket_set_blocking($client, 0);

$time1 = time();

fwrite($client, 'Hello Server');

echo "其他业务" . PHP_EOL;

echo (time() - $time1) . '秒' . PHP_EOL;

while (! feof($client)) {
    $data = fread($client, 66535);

    var_dump(strlen($data) . PHP_EOL);
    var_dump($data . PHP_EOL);
    sleep(1);
}

//fclose($client);